'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview vip等级
 * @author sundbcn@gmail.com (sun debing)
 */

var moment = require('moment');
var modelUtil = require('../util/modelUtil');
var constantUtil = require('../util/constantUtil');
var mongoConnector = require('../libs/mongodb/mongoConnector');
/* jshint unused:false */
var marqueeSchema = require('../schemas/marqueeSchema');
var Marquee = mongoConnector().model('Marquee');
var mongoose = require('mongoose');
var ObjectId = mongoose.Types.ObjectId;

module.exports.create = function (list, cb) {
    Marquee.create({
        sort_id: list.sort_id,
        text: list.text,
        is_time: list.is_time,
        times: list.times,
        interval_time: list.interval_time,
        create_time: list.create_time
    }, cb);
};

module.exports.find = function (cb) {
    var where = {
        times: {
            $gte: 1
        }
    };

    Marquee.find(where)
        .select('')
        .exec(cb);
};

module.exports.findOne = function (id, cb) {
    Marquee.findOne({
        _id: new ObjectId(id)
    }, cb);
};

module.exports.del = function (id, cb) {
    Marquee.remove({
        _id: new ObjectId(id)
    }, cb);
};

module.exports.removeInvlid = function (cb) {
    Marquee.remove({
        times: {
            $lt: 1
        }
    }, cb);
};
